﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace FilterExampleByLambda
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = Enumerable.Range(1, 100).ToList();
            Filter(list, x => x % 2 == 0);

            var xCollection = new double[] { 0, 0.1, 0.2, 0.3, 0.4 };
            var yCollection = F(xCollection, x => Math.Sin(x) + x * x);

        }

        static double[] F(double[] collection, Func<double, double> f)
        {
            var result = new double[collection.Length];

            for (int i = 0; i < collection.Length; i++)
            {
                result[i] = f(collection[i]);
            }

            return result;
        }

        static List<int> Filter(List<int> collection, Func<int, bool> filter)
        {
            List<int> filteredValues = new List<int>();

            foreach (var item in collection)
            {
                if (filter(item))
                {
                    filteredValues.Add(item);
                }
            }

            return filteredValues;
        }


    }
}
